package com.sokal.easycare.modules.order.entity;

import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import com.sokal.easycare.common.persistence.DataEntity;
import com.sokal.easycare.modules.order.entity.additional.OmOrderAdditional;
import com.sokal.easycare.modules.order.entity.item.UserOrderItem;
import com.sokal.easycare.modules.order.entity.track.OmOrderTrack;
import com.sokal.easycare.modules.sys.entity.FileLibrary;
import com.sokal.easycare.modules.sys.entity.MainUser;
import com.sokal.easycare.modules.sys.entity.UserAddr;

/**
 * 订单相关Entity
 * 
 * @author nibo
 * @version 2017-03-16
 */
public class UserOrder extends DataEntity<UserOrder> {

	private static final long serialVersionUID = 1L;
	private String orderCode; // 系统自由编码定义，保留
	private String userId; // 用户id 必须
	private MainUser user;
	private OmOrderTrack omOrderTrack; // 订单跟踪信息
	private String addressId; // 地址信息标示。必须
	private UserAddr userAddr; // 地址信息标示。必须
	private String contactId; // 联系信息 必须
	private String contractId; // 合同id
	private String orderPriority; // 优先级别，00S标示优先，000标示普通
	private String orderState; // 订单状态
	private String orderType; // 订单类型
	private String itemPrice; // 总金额
	private String paymentPrice; // 已支付金额
	private String status; // 状态(逻辑删除) 0:未删除,1:已删除
	private String comments; // 备注
	private String executeSystem; // 涉及用户佣金的操作，由线下操作人员和运营部执行 对接EXECUTE_SYSTEM的标识
	private Date stateDate; // 状态时间
	private Integer warrantyTime ; // 保质期
	private Date finishDate; // 可人工或自动写入，没有写入的就和定单的状态非竣工的时间相同
	private List<UserOrderItem> userOrderItems;// 订单项 必须
	private List<OmOrderAdditional> orderAdditionals;// 评价于疑问
	private List<FileLibrary> fileLibraries = Lists.newArrayList(); //获取设计师上传设计图片或项目经理上传施工文件，图片

	public List<OmOrderAdditional> getOrderAdditionals() {
		return orderAdditionals;
	}

	public void setOrderAdditionals(List<OmOrderAdditional> orderAdditionals) {
		this.orderAdditionals = orderAdditionals;
	}

	public UserOrder() {
		super();
	}

//	public UserOrder(String id) {
//		super(id);
//	}
	

	public UserOrder(String orderCode){
		this.orderCode=orderCode;
	}

	public int getWarrantyTime() {
		return warrantyTime;
	}

	public void setWarrantyTime(int warrantyTime) {
		this.warrantyTime = warrantyTime;
	}

	public String getContractId() {
		return contractId;
	}

	public void setContractId(String contractId) {
		this.contractId = contractId;
	}

	@Length(min = 1, max = 255, message = "系统自由编码定义，保留长度必须介于 1 和 255 之间")
	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getAddressId() {
		return addressId;
	}

	public void setAddressId(String addressId) {
		this.addressId = addressId;
	}

	public String getContactId() {
		return contactId;
	}

	public void setContactId(String contactId) {
		this.contactId = contactId;
	}

	@Length(min = 0, max = 3, message = "优先级别，00S标示优先，000标示普通长度必须介于 0 和 3 之间")
	public String getOrderPriority() {
		return orderPriority;
	}

	public void setOrderPriority(String orderPriority) {
		this.orderPriority = orderPriority;
	}

	@Length(min = 0, max = 3, message = "order_state长度必须介于 0 和 3 之间")
	public String getOrderState() {
		return orderState;
	}

	public void setOrderState(String orderState) {
		this.orderState = orderState;
	}

	@Length(min = 0, max = 3, message = "order_type长度必须介于 0 和 3 之间")
	public String getOrderType() {
		return orderType;
	}

	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}

	public String getItemPrice() {
		return itemPrice;
	}

	public void setItemPrice(String itemPrice) {
		this.itemPrice = itemPrice;
	}

	@Length(min = 0, max = 3, message = "status长度必须介于 0 和 3 之间")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Length(min = 0, max = 4000, message = "comments长度必须介于 0 和 4000 之间")
	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	@Length(min = 0, max = 3, message = "涉及用户佣金的操作，由线下操作人员和运营部执行            对接EXECUTE_SYSTEM的标识长度必须介于 0 和 3 之间")
	public String getExecuteSystem() {
		return executeSystem;
	}

	public void setExecuteSystem(String executeSystem) {
		this.executeSystem = executeSystem;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message = "状态时间不能为空")
	public Date getStateDate() {
		return stateDate;
	}

	public void setStateDate(Date stateDate) {
		this.stateDate = stateDate;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getFinishDate() {
		return finishDate;
	}

	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}

	public List<UserOrderItem> getUserOrderItems() {
		return userOrderItems;
	}

	public void setUserOrderItems(List<UserOrderItem> userOrderItems) {
		this.userOrderItems = userOrderItems;
	}

	public String getPaymentPrice() {
		return paymentPrice;
	}

	public void setPaymentPrice(String paymentPrice) {
		this.paymentPrice = paymentPrice;
	}

	public MainUser getUser() {
		return user;
	}

	public void setUser(MainUser user) {
		this.user = user;
	}

	public OmOrderTrack getOmOrderTrack() {
		return omOrderTrack;
	}

	public void setOmOrderTrack(OmOrderTrack omOrderTrack) {
		this.omOrderTrack = omOrderTrack;
	}

	public UserAddr getUserAddr() {
		return userAddr;
	}

	public void setUserAddr(UserAddr userAddr) {
		this.userAddr = userAddr;
	}

	@Override
	public String toString() {
		return "UserOrder [orderCode=" + orderCode + ", userId=" + userId + ", addressId=" + addressId + ", contactId="
				+ contactId + ", orderPriority=" + orderPriority + ", orderState=" + orderState + ", orderType="
				+ orderType + ", itemPrice=" + itemPrice + ", paymentPrice=" + paymentPrice + ", status=" + status
				+ ", comments=" + comments + ", executeSystem=" + executeSystem + ", stateDate=" + stateDate
				+ ", finishDate=" + finishDate + "]";
	}

	public List<FileLibrary> getFileLibraries() {
		return fileLibraries;
	}

	public void setFileLibraries(List<FileLibrary> fileLibraries) {
		this.fileLibraries = fileLibraries;
	}

}